﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NL.ADA.ConfigService.DAL.EntityClasses;
using NL.ADA.ConfigService.DAL.DatabaseSpecific;
using NL.ADA.ConfigService.DAL.FactoryClasses;
using NL.ADA.ConfigService.DAL.HelperClasses;
using NL.ADA.ConfigService.DAL.RelationClasses;
using NL.ADA.ConfigService.DAL;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace NL.ADA.ConfigClient
{
    public class ModeManager:ManagerBase<ApplicationModeModifiedEntity>
    {
        public virtual int GetModeIdByCode(string code)
        {
            ModeEntity result = new ModeEntity();
            result.Name = code;
            try
            {
                using (DataAccessAdapter adapter = new DataAccessAdapter())
                {
                    IPredicateExpression expr = new PredicateExpression(ModeFields.Name == code);
                    adapter.FetchEntityUsingUniqueConstraint(result,expr);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result.Id;

        }
    }
}
